var recommendservice = require("../../../apiservice/recommend/recommendservice");
// pages/promotion/detail/detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    Recommend: null,
    Recommendid: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    //console.log(options);
    this.QueryRecommendById(options.id);
    this.setData({
      Recommendid: options.id
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  makeCall:function(){
    if (this.data.Recommend.address1_Telephone1){
      wx.makePhoneCall({
        phoneNumber: this.data.Recommend.address1_Telephone1,
      })
    }
  },
  modRecommond: function () {
    var id = this.data.Recommendid;
    var hosid = this.data.Recommend.new_hospital;
   // var data = this.data.Recommend;
    //console.log(data);
    wx.navigateTo({
      url: '/pages/promotion/modify/modify?id='+id+'&hosid='+hosid
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  // 根据记录ID获取记录
  QueryRecommendById: function (id) {
    var that = this;
    recommendservice.QueryRecommendById(id).then(function (success) {
      console.log( success.data);
      that.setData({
        Recommend: success.data
      });
    }).catch(function (ex) {
      console.log(ex);
    })
  }
})